#include <iostream>

template<typename T>
class Stack {
private:
    int top;
    int size;
    T* data;
public:
    Stack(int s) : top(-1), size(s) {
        data = new T[size];
    }
    ~Stack() {
        delete[] data;
    }
    void push(T val) {
        if (top == size - 1) {
            std::cout << "Stack is full!" << std::endl;
            return;
        }
        data[++top] = val;
    }
    T pop() {
        if (top == -1) {
            std::cout << "Stack is empty!" << std::endl;
            return T();
        }
        return data[top--];
    }
};
